home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / AEavgNurbsSurfacePointsTempl < prev    next >
Encoding:
Text File  |  2003-07-17  |  6.1 KB  |  225 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //
  20. //  Creation Date:    July 9, 1997
  21. //  Author:        sw
  22. //
  23. //  Procedure Name:
  24. //    AEavgNurbsSurfacePointsTemplate
  25. //
  26. //  Description Name;
  27. //    Creates the attribute editor controls for the 
  28. //    avgNurbsSurfacePoints Node
  29. //
  30. //  Input Value:
  31. //    nodeName 
  32. //
  33. //  Output Value:
  34. //    None
  35. //
  36.  
  37. global proc AEavgNurbsSurfacePointsTemplate ( string $nodeName )
  38. {
  39.     editorTemplate -beginScrollLayout;
  40.  
  41.     editorTemplate -beginLayout "Average NURBS Surface Points History" -collapse false;
  42.         editorTemplate -callCustom
  43.                 "AEsurfacePointNew"
  44.                 "AEsurfacePointReplace"
  45.                 "surfacePoint";
  46.     editorTemplate -endLayout;
  47.  
  48.     // suppressed attributes
  49.     editorTemplate -suppress "inputSurface";
  50.     editorTemplate -suppress "surfacePoint";
  51.  
  52.     // include/call base class/node attributes
  53.     AEdependNodeTemplate $nodeName;
  54.  
  55.     editorTemplate -addExtraControls;
  56.     editorTemplate -endScrollLayout;
  57. }
  58.  
  59.  
  60. proc AEconnectSurfacePointControls( string $plug, string $srfPt )
  61. {
  62.  
  63.     string $number[];
  64.     tokenize($srfPt, "[]", $number);
  65.     string $name = ($number[0] + $number[1]);
  66.  
  67.     // get the index
  68.     //
  69.     string $buffer[];
  70.     tokenize($srfPt,"[]",$buffer);
  71.     string $index = $buffer[1];
  72.  
  73.     // get the nodeName
  74.     //
  75.     clear $buffer;
  76.     tokenize($plug,".",$buffer);
  77.     string $nodeName = $buffer[0];
  78.  
  79.     // build the plug name
  80.     //
  81.     string $plugName = $nodeName+"."+$srfPt;
  82.  
  83.     // get the input node
  84.     //
  85.     string $inputAttr = ($plugName+".inputSurface");
  86.     string $inputNode[] = `listConnections -d false -sh true $inputAttr`;
  87.  
  88.     text -e -l ("Surface Point["+$index+"]") srfPtLabel;
  89.     textField -e -tx $inputNode[0] srfPtInput;
  90.     connectControl ($name + "Weight") ($plugName+".weight");
  91.     connectControl ($name + "Floats") -index 2 ($plugName+".parameterU");
  92.     connectControl ($name + "Floats") -index 3 ($plugName+".parameterV");
  93.     connectControl ($name + "Ints") -index 2 ($plugName+".cvIthIndex");
  94.     connectControl ($name + "Ints") -index 3 ($plugName+".cvJthIndex");
  95. }
  96.  
  97.  
  98. proc AEcreateNewSurfacePointControls( string $nodeName, string $srfPt )
  99. {
  100.     string $number[];
  101.     tokenize($srfPt, "[]", $number);
  102.     string $name = ($number[0] + $number[1]);
  103.  
  104.     string $inputAttr = ($nodeName+"."+$srfPt+".inputSurface");
  105.     string $connections[] = `listConnections -p true $inputAttr`;
  106.     string $conInput[];
  107.     tokenize($connections[0], ".", $conInput);
  108.  
  109.     setUITemplate -pst attributeEditorTemplate;
  110.     columnLayout -adj true;
  111.         separator ($name + "Sep");
  112.         rowLayout -nc 4;
  113.             text srfPtLabel;
  114.             textField -ed false srfPtInput;
  115.             if ($conInput[0] == ""){
  116.                 symbolButton -i "inArrow.xpm" -en 0 
  117.                     goToConnectedInput;
  118.             } else {
  119.                 symbolButton -i "inArrow.xpm" 
  120.                     -c ("AEgoToConnected " + $conInput[0] )
  121.                     goToConnectedInput;
  122.             }
  123.         setParent ..;
  124.         floatSliderGrp -f 1 -min 0 -max 1 -l "Weight" ($name + "Weight");
  125.         floatFieldGrp -nf 2 -l "Parameters UV" ( $name + "Floats");
  126.         intFieldGrp -nf 2 -l "Index IJ" ($name + "Ints");
  127.     setParent ..;
  128.  
  129.     AEconnectSurfacePointControls( $nodeName, $srfPt );
  130.     setUITemplate -ppt;
  131. }
  132.  
  133.  
  134. global proc AEsurfacePointNew( string $plug )
  135. {
  136.  
  137.     // get the nodeName
  138.     //
  139.     string $buffer[];
  140.     tokenize($plug,".",$buffer);
  141.     string $nodeName = $buffer[0];
  142.  
  143.     // get all of the elements of the array
  144.     //
  145.     string $tmpPoints[] = `listAttr -m $plug`;
  146.     string $surfacePoints[];
  147.     for ($tmp in $tmpPoints) {
  148.         string $tmpBuffer[];
  149.         tokenize($tmp,".",$tmpBuffer);
  150.         if (size($tmpBuffer) == 1) {
  151.             $surfacePoints[size($surfacePoints)] = $tmp;
  152.         }
  153.     }
  154.     int $numSurfacePoints = size($surfacePoints);
  155.  
  156.     setUITemplate -pst attributeEditorTemplate;
  157.     columnLayout AEsurfacePointLayout;
  158.     for ( $srfPt in $surfacePoints ) {
  159.         AEcreateNewSurfacePointControls($nodeName, $srfPt);
  160.     }
  161.     setParent ..;
  162.     setUITemplate -ppt;
  163.  
  164. }
  165.  
  166.  
  167. global proc AEsurfacePointReplace( string $plug )
  168. {
  169.     // get the nodeName
  170.     //
  171.     string $buffer[];
  172.     tokenize($plug,".",$buffer);
  173.     string $nodeName = $buffer[0];
  174.  
  175.     string $tmpPoints[] = `listAttr -m $plug`;
  176.     string $newSurfacePoints[];
  177.     for ($tmp in $tmpPoints) {
  178.         string $tmpBuffer[];
  179.         tokenize($tmp,".",$tmpBuffer);
  180.         if (size($tmpBuffer) == 1) {
  181.             $newSurfacePoints[size($newSurfacePoints)] = $tmp;
  182.         }
  183.     }
  184.     int $newNumSurfacePoints = size ($newSurfacePoints);
  185.     string $oldSurfacePointLayouts[] = `columnLayout -q -ca AEsurfacePointLayout`;
  186.     int $oldNumSurfacePoints = size ($oldSurfacePointLayouts);
  187.  
  188.     setParent AEsurfacePointLayout;
  189.  
  190.     if ( $newNumSurfacePoints >= $oldNumSurfacePoints ) {
  191.  
  192.         // replace what we can
  193.         //
  194.         for ( $i = 0; $i < $oldNumSurfacePoints; $i++ ) {
  195.             setParent $oldSurfacePointLayouts[$i];
  196.             AEconnectSurfacePointControls($nodeName, $newSurfacePoints[$i]);
  197.         }
  198.  
  199.         // and build what we need
  200.         //
  201.         setParent AEsurfacePointLayout;
  202.         for ( $i = $oldNumSurfacePoints; $i < $newNumSurfacePoints; $i++ ) {
  203.             AEcreateNewSurfacePointControls($nodeName, $newSurfacePoints[$i]);
  204.         }
  205.  
  206.  
  207.     } else {
  208.  
  209.         // replace what we need
  210.         //
  211.         for ( $i = 0; $i < $newNumSurfacePoints; $i++ ) {
  212.             setParent $oldSurfacePointLayouts[$i];
  213.             AEconnectSurfacePointControls($nodeName, $newSurfacePoints[$i]);
  214.         }
  215.  
  216.         // delete old columnLayouts
  217.         //
  218.         setParent AEsurfacePointLayout;
  219.         for ( $i = $newNumSurfacePoints; $i < $oldNumSurfacePoints; $i++ ) {
  220.             deleteUI -layout $oldSurfacePointLayouts[$i];
  221.         }
  222.  
  223.     }
  224. }
  225.